package com.kdx.cloud.common.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kdx.cloud.common.dao.DictionaryMapper;
import com.kdx.cloud.common.domain.Dictionary;

@Service
public class DictionaryService {
	@Autowired
	private DictionaryMapper dictionaryMapper;

	// @Cacheable
	public List<Dictionary> getDictListFromCache(String dictTable) {
		List<Dictionary> dictionarys = dictionaryMapper.getDictionaryByType(dictTable);
		return dictionarys;
	}

	// @Cacheable
	public Map<String, String> getDictMapFromCache(String type) {
		HashMap<String, String> dictMap = new HashMap<String, String>();
		List<Dictionary> list = getDictListFromCache(type);
		for (Dictionary dict : list) {
			dictMap.put(dict.getId(), dict.getName());
		}
		return dictMap;
	}
}
